#include "lib.h"

#include "brathand.h"
#include "cardmgr.h"

#define SELF	BratHand
#define SUPER	Hand

BratHand::BratHand(CardMgr* Mgr)
	: Hand(Mgr)
{
}

bool8
BratHand::natural()
{
	int32 total = score();

	return (bool8)(getCount() == 2 && (total == 8 || total == 9));
}

int32
BratHand::score()
{
	int32 i, result = 0;

	for (i = 0; i < getCount(); i++)
	{
		result += cardScore(cards[i]);

		if (result >= 10)
			result -= 10;
	}

	return result;
}

int32
BratHand::cardScore(uint8 Card)
{
	int32 rank = mgr->getRank(Card);

	if (rank < 10)
		return rank;
	else if (rank == CardMgr::ACE)
		return 1;
	else
		return 0;
}
